package mr.zhang.controller;

import mr.zhang.service.TestMyBatisService;
import mr.zhang.util.PageModelMerChant;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;



public class QueryMerChantController extends AbstractController {
	
	private String toview;
	
	private TestMyBatisService testMyBatisService;
	
	public String getToview() {
		return toview;
	}



	public void setToview(String toview) {
		this.toview = toview;
	}



	
	
	

	public TestMyBatisService getTestMyBatisService() {
		return testMyBatisService;
	}



	public void setTestMyBatisService(TestMyBatisService testMyBatisService) {
		this.testMyBatisService = testMyBatisService;
	}



	
	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		
		int offset = 0;
		
		int pagesize = 10;
		
		try{
			
			offset = Integer.parseInt(request.getParameter("pager.offset"));
			
			
			}catch (Exception e) {
				// TODO: handle exception
				
				System.out.println("类型转化失败");
			}
		
		PageModelMerChant pageModelMerChant = this.testMyBatisService.queryMerchant(offset,  pagesize);
		
		Map<String,Object> model = new HashMap<String,Object>();
		
		model.put("pageModelMerChant", pageModelMerChant);
		
		
 		
		return new ModelAndView(getToview(),model);
	}

}
